#ifndef  H_A2NET
#define  H_A2NET

#ifndef H_A2SYSDEF
# include "a2sysdef.h"
#endif

#ifndef __WATCOMC__
#if (__TURBOC__ >= 0x460) || (_MSC_VER >= 800)
# include <pshpack1.h>
#endif
#endif

#ifdef __cplusplus
 extern "C" {
#endif

/*------------*/
/* A2NETDIO.C */
/*------------*/
#ifdef    H_A2SYSDEF
  enum _netlink_mode_ {A2NET_CFGFILE, A2NET_DIRNAME, A2NET_UNIQUE};
  A2EXT int  A2PAS a2NetLink (int mode, char *name);
  A2EXT void A2PAS a2NetOff (int KeepName);
# define NKNETWORK(cfgfile) a2NetLink(A2NET_CFGFILE, cfgfile)
# define NKNetOff(ExitCode) a2NetOff(0)
#endif /* H_A2SYSDEF */

/*-----------*/
/* A2NET00.C */
/*-----------*/
#ifdef    H_A2SYSDEF
  A2EXT int A2PAS a2netEnvironment(void);
  A2EXT int A2PAS a2netConnect    (char *serverName);
  A2EXT int A2PAS a2netDisConnect (int channel);
  A2EXT int A2PAS a2netGetAddr    (char mode, char *network, char *card);
# define a2NetIPX_Addr a2netGetAddr
#endif /* H_A2SYSDEF */

#if defined(FULL_A2NET00) && !defined(H_A2NIKA)
  int a2netChkChannel (int channel);
  int a2netTstDAbf    (int channel);
# define MAX_N_SERVER  5 /* max number of servers for one station */
# define CH_OPEN       1
  extern int A2NameRegistered;
  int a2netRegister   (char *localName);
  int a2netUnregister (char *name);
  int a2netSend       (int channel, void *data, unsigned datalen);
  int a2netReceive    (int channel, void *buff, unsigned bufflen);
#endif

/*------------*/
/* A2NETRES.C */
/*------------*/
#ifdef    H_A2SYSDEF
  A2EXT long A2PAS a2ResourceOpen  (char *server, char *name);
  A2EXT int  A2PAS a2ResourceClose (long hResource);
# define A2RES_CLOSEALL (-17)
  A2EXT int  A2PAS a2ResourceTest  (long hResource, int *open, int *lock);
  /*   *lock={0-not locked, (<0)-our lock, (>0)-other lock} */
  A2EXT int A2PAS a2ResourceLock  (long hResource);
  A2EXT int A2PAS a2ResourceUnlock(long hResource);
  A2EXT int A2PAS a2ResourceRead  (long hResource, int type, void *buf);
  A2EXT int A2PAS a2ResourceWrite (long hResource, int type, void *buf);
  /* type: 'c' -- char                         */
  /*       'i' -- int                          */
  /*       'l' -- long                         */
  /*       'f' -- float                        */
  /*       'd' -- double                       */
  /*       's' -- string (max length == 32)    */
  /*       'm' -- memory (continious 32 bytes) */
#endif /* H_A2SYSDEF */

/*-----------*/
/* A2NETIO.C */
/*-----------*/
#ifdef    H_A2SYSDEF
 A2EXT int  A2PAS a2_exist  (char *fname);
 A2EXT int  A2PAS a2_fullnm (char *fullnm, char *fname, char disp);
 A2EXT int  A2PAS a2_open   (char *fname, int mode);
 A2EXT int  A2PAS a2_creat  (char *fname, int mode);
 A2EXT int  A2PAS a2_unlink (char *fname);
 A2EXT int  A2PAS a2_close  (int fh);
 A2EXT int  A2PAS a2_read   (int fh, void *buf, unsigned int len);
 A2EXT int  A2PAS a2_write  (int fh, void *buf, unsigned int len);
 A2EXT long A2PAS a2_lseek  (int fh, long fPos, int mode);
 A2EXT long A2PAS a2_filelength (int fh);
#endif /* H_A2SYSDEF */

/*------------*/
/* A2NETADM.C */
/*------------*/
enum {
   A2SI_rqMEMFREE,     /* long           */
   A2SI_rqDISKFREE,    /* long           */
   A2SI_rqGLOBALINF,   /* A2SI_GLOBALINF */
   A2SI_rqCLIENTS,     /* 16-byte names  */
   A2SI_rqDAFILES,     /* name1\0name2...*/
   A2SI_rqRESOURCES,   /* 16-byte names  */
   A2SI_rqNNN
};
typedef struct {
   short Version;
   short Flags; /* (Flags & 1) -- Connection enabled      */
                /* (Flags & 2) -- Asked for disconnection */
                /* (Flags & 4) -- 32 bit server           */
   short max_Clients,   act_Clients;
   short max_Files,     act_Files;
   short max_Resources, act_Resources;
   short max_Processes, act_Processes;
   short max_Buffers,   act_Buffers;
   short transWait,     transIdle;
   short blkSz;
} A2SI_GLOBALINF;

typedef struct {
   short ndisks; long space[64];
} A2SI_DFREE;

#ifdef    H_A2SYSDEF
  A2EXT int A2PAS a2_login(char *server, char *psw);
  A2EXT int A2PAS a2_logout  (int ch);
  A2EXT int A2PAS a2netAdmServerInfo (char *server, int index, void *buf);
  /* ret: >= 0 -- OK; -1 -- bad index; -2 -- no mem; ... */
#endif /* H_A2SYSDEF */

#if !defined(__FOR_WINDOWS__) && !defined(__FOR_WIN32__)
  int a2netDisconAlarm (int seconds);
  int a2netDisconTest (int noShow);
#endif

#if defined(FULL_A2NET00) && !defined(H_A2NIKA)
  int a2netAdmServerList (char *buf, int (*hook)(int ticks, char *name));
#endif

#if defined(SERVER) || defined(FULL_A2NET00)
  typedef struct {
     unsigned short flags, ftime,fdate;
     long                        fsize;
     char            attrib, name[127];
  } A2FF_INFO;
#endif

#if defined(FULL_A2NET00) && !defined(H_A2NIKA)
 int a2_emuscr  (int ch, int Key, char *bf);
 int a2_datime  (int ch, int set, struct a2datetm *pdt);
 int a2_getdisk (int ch);
 int a2_setdisk (int ch, int drive);
 int a2_diskfree(int ch, int drive, unsigned *t_c, unsigned *a_c, long *csz);
 int a2_rddir   (int ch, char *dir);
 int a2_chdir   (int ch, char *dir);
 int a2_mkdir   (int ch, char *dir);
 int a2_rmdir   (int ch, char *dir);
 int a2_rename  (int ch, char *oldname, char *newname);
 int a2_filefind(int ch, int first, char *wildcard, A2FF_INFO *fi, int bsz);
 int a2_getftime(int fh, unsigned *dt, unsigned *tm);
 int a2_setftime(int fh, unsigned  dt, unsigned  tm);
#endif

#ifdef __cplusplus
 }
#endif

#ifndef __WATCOMC__
#if (__TURBOC__ >= 0x460) || (_MSC_VER >= 800)
# include <poppack.h>
#endif
#endif

#endif /*H_A2NET*/
